package at.fhj.itm11.forum.service;

import javax.ejb.Stateless;
import javax.enterprise.event.Event;
import javax.inject.Inject;
import javax.persistence.EntityManager;

import at.fhj.itm11.forum.model.Post;

// The @Stateless annotation eliminates the need for manual transaction demarcation
@Stateless
public class PostRegistration {

   @Inject
   private EntityManager em;

   @Inject
   private Event<Post> postEventSrc;

   public void register(Post post) throws Exception {
      em.persist(post);
      postEventSrc.fire(post);
   }
}
